package com.edu.common.utils.reflect;

import org.springframework.core.ResolvableType;

public class SpringReflectUtils {


    /**
     * 获取接口的第一泛型值
     * @param clazz
     * @return
     */
    public static Class getInterfaceFirstGenericType(Class clazz) {
        ResolvableType resolvableType = ResolvableType.forClass(clazz);
        for (ResolvableType anInterface : resolvableType.getInterfaces()) {
            for (ResolvableType generic : anInterface.getGenerics()) {
                return generic.resolve();
            }
        }
        return null;
    }


}
